<?php

class InformationController extends Controller
{
	public function filters()
	{
		return array(
			'rights', // perform access control for CRUD operations

		);
	}
	public function init(){
		Yii::app()->theme = 'admincp';
		$this->layout = '//layouts/admincp';
	}
	public function actionIndex($id=null)
	{
		$model = Infomations::model()->findByPk($id);
		if($model === null)
			throw new CHttpException('404','Không tìm thấy trang');
		
		if(!empty($_POST['Infomations'])){
			$model->attributes = $_POST['Infomations'];
			$model->content = $_POST['Infomations']['content'];
			$model->created = time();
			if($model->save())
				Yii::app()->user->setFlash('success', "Cập nhật thành công.");
		}
		$this->pageTitle = $model->name;
		$this->render('index',array('model'=>$model));
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}